<template>
	<view>
		<!-- 聊天事件 -->
			<view v-if="shortTime" class="py-2 flex align-center justify-center font-sm text-light-muted">
				{{shortTime}}
			</view>
		<!-- 聊天气泡 -->
		<view class="flex align-start px-2 my-2" :style="isSelf ? 'flex-direction: row-reverse;' : ''">
			<image :src="item.avatar ? item.avatar : '/static/default.jpg'" style="width: 100rpx; height: 100rpx;"
			class="rounded-circle"></image>
			<view class="bg-light p-2 rounded mx-2"style="max-width: 400rpx;">
				{{item.data}}
			</view>
		</view>
	</view>
</template>

<script>
	import $T from '@/common/time.js'
	export default {
		props:{
			item:Object,
			index:Number,
			pretime:[Number,String]
		},
		computed:{
			//计算哪条消息是本人
			isSelf(){
				let myId=  this.$store.state.userinfo.id
				return this.item.user_id === myId
			},
			//计算显示时间
			shortTime(){
				return $T.getChatTime(this.item.create_time,this.pretime)
			}
		},
		created() {
			console.log('-----------------------------',this.item)
		},
	}
</script>

<style>
</style>
